package cn.mickey.exchange.domain.model;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@Accessors(chain = true)
@TableName("ie_message")
public class MessageModel implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId
    private Long messageId;

    /**
     * 所有留言的用户id
     */
    private Long userId;
    /**
     * 所有留言的用户
     */
    @TableField(exist = false)
    private UserModel fromU;

    /**
     * 闲置主键id
     */
    private Long idleId;
    @TableField(exist = false)
    private IdleItemModel idle;

    /**
     * 留言内容
     */
    private String content;

    /**
     * 留言时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 所回复的用户id
     */
    private Long toUser;

    /**
     * 所回复的用户
     */
    @TableField(exist = false)
    private UserModel toU;

    /**
     * 所回复的留言id
     */
    private Long toMessage;

    /**
     * 所回复的留言id
     */
    @TableField(exist = false)
    private MessageModel toM;

}